package com.example.studentcompetitionplatform.service.impl;

import com.example.studentcompetitionplatform.entity.Competitions;
import com.example.studentcompetitionplatform.entity.Registrations;
import com.example.studentcompetitionplatform.mapper.GeRenXinXiMapper;
import com.example.studentcompetitionplatform.service.IGeRenXinXiService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@Service
public class GeRenXinXiService implements IGeRenXinXiService {
    @Resource
    private GeRenXinXiMapper geRenXinXiMapper;

    @Override
    public void deleteR(Registrations registrations) {
        geRenXinXiMapper.deleteRG(registrations);
    }

    @Override
    public Map<String, Object> page(Integer pageNum, Integer pageSize, Integer registrationId,Integer userId) {
        pageNum = (pageNum - 1) * pageSize;
        if (registrationId == 0) {
            registrationId = null;
        }
        List<Registrations> data = geRenXinXiMapper.selectPage(pageNum, pageSize, registrationId,userId);
        Integer total = geRenXinXiMapper.findUserTotal(registrationId);
        Map<String, Object> res = new HashMap<>();
        res.put("data", data);
        res.put("total", total);
        return res;
    }
}
